package iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wcj
 * @Date 2021/7/4 20:30
 * @Version 1.0
 */
public class ConcreteAggregate extends Aggregate {

    private List<Object> items = new ArrayList<>();

    @Override
    public Iterator createIterator() {
        return new ConcreteIterator(this);
    }

    public int count() {
        return items.size();
    }

    public Object index(int idx) {
        return this.items.get(idx);
    }

    public void setObj(Object obj) {
        this.items.add(obj);
    }

}
